<%@ page import="com.wanmait.computershop.vo.Orderdetle" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <!--edge浏览器H5兼容设置-->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!--360浏览器H5兼容设置-->
    <meta name="renderer" content="webkit" />
    <title>电脑商城</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!--导入核心文件-->
    <script src="/computershop/static/web/bootstrap3/js/holder.js"></script>
    <link href="/computershop/static/web/bootstrap3/css/bootstrap.css" rel="stylesheet" type="text/css">
    <script src="/computershop/static/web/bootstrap3/jquery-1.9.1.min.js"></script>
    <script src="/computershop/static/web/bootstrap3/js/bootstrap.js"></script>
    <!-- 字体图标 -->
    <link rel="stylesheet" href="/computershop/static/web/bootstrap3/font-awesome-4.7.0/css/font-awesome.css" />
    <link rel="stylesheet" type="text/css" href="/computershop/static/web/css/layout.css" />
    <link rel="stylesheet" type="text/css" href="/computershop/static/web/css/top.css" />
    <link rel="stylesheet" type="text/css" href="/computershop/static/web/css/footer.css" />
    <link rel="stylesheet" type="text/css" href="/computershop/static/web/css/order.css" />
</head>

<body>
<!--头部-->
<jsp:include page="/WEB-INF/web/inc/header.jsp"></jsp:include>
<!--头部结束-->
<!--导航结束-->
<div class="container">
    <div class="col-md-2">
        <!--左侧导航开始-->
        <div class="panel-group" id="accordion">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <!--主选项：我的订单-->
                    <p class="panel-title">
                        <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">我的订单</a>
                    </p>
                </div>
                <div id="collapseOne" class="panel-collapse collapse in">
                    <div class="panel-body">
                        <div><a href="orders.html"><b>全部订单</b></a></div>
                        <div><a href="orders.html">待付款</a></div>
                        <div><a href="orders.html">待收货</a></div>
                        <div><a href="orders.html">待评价</a></div>
                        <div><a href="orders.html">退货退款</a></div>
                    </div>
                </div>
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <!--主选项：资料修改-->
                    <p class="panel-title">
                        <a data-toggle="collapse" data-parent="#accordion" href="#collapseTwo">资料修改</a>
                    </p>
                </div>
                <div id="collapseTwo" class="panel-collapse collapse">
                    <div class="panel-body">
                        <div><a href="password.html"><b>修改密码</b></a></div>
                        <div><a href="userdata.html">个人资料</a></div>
                        <div><a href="upload.html">上传头像</a></div>
                        <div><a href="address.html">收货管理</a></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--左侧导航结束-->
    <div class="col-md-10">

        <c:forEach items="${requestScope.orderList}" var="order">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <p class="panel-title">
                        订单号：${order.orderNum}，下单时间：${order.orderTime} ，收货人：${order.recvName} <br>

                        收货地址：${order.provinceName}${order.cityName}${order.areaName}${order.detailName} ，电话：${order.orderPhone}
                    </p>
                </div>
                <div class="panel-body">
                    <table class="orders-table" width="100%">
                        <thead>
                        <tr>
                            <th width="15%"></th>
                            <th width="30%">商品</th>
                            <th width="8%">单价</th>
                            <th width="8%">数量</th>
                            <th width="9%">小计</th>
                            <th width="10%">售后</th>
                            <th width="10%">状态</th>
                            <th width="10%">操作</th>
                        </tr>
                        </thead>
                        <tbody class="orders-body">
                        <c:forEach items="${order.orderdetleList}" var="orderdetle">
                            <tr>
                                <td><img src="/computershop/static/web${orderdetle.product.image}collect.png" class="img-responsive" /></td>
                                <td>${orderdetle.product.title}</td>
                                <td>¥<span>${orderdetle.product.price}</span></td>
                                <td>${orderdetle.BNum}件</td>
                                <td>¥<span class="subtotal">${orderdetle.product.price*orderdetle.BNum}</span></td>
                                <td><a href="#">申请售后</a></td>
                                <td>
                                    <div>未发货</div>
<%--                                    <div><a href="orderInfo.html">订单详情</a></div>--%>
                                </td>
                                <td><a href="#" class="btn btn-default btn-xs">去支付</a></td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                    <div>
                        <span style="margin-left: 730px">订单总金额：¥</span><span class="pull-right" style="font-weight: bold;color: red;margin-left: 10px"></span>
                    </div>
                </div>
            </div>
        </c:forEach>
        <script>
            $(function (){
                var totals = $(".pull-right");
                    for (let i = 0; i < totals.length; i++) {
                     var subtotals = $(totals[i]).parent().parent().find(".subtotal");
                     var total = 0;
                     total = parseInt(total);
                        for (let j = 0; j < subtotals.length; j++)
                        {
                            total += parseInt($(subtotals[j]).text());
                        }
                        $(totals[i]).text(total);
                }
            });
        </script>

    </div>
</div>
<!--页脚开始-->
<jsp:include page="/WEB-INF/web/inc/foot.jsp"></jsp:include>
<!--页脚结束-->
</body>

</html>
